﻿using System.Collections.Generic;
using System.Linq;

namespace Vibstudio.X4NET.Collections
{
    public class OperationResultCollection : ResultCollectionBase<OperationResult>
    {
        public override bool ThereAreErrors
        {
            get { return this.Any(x => !x.IsPerformed); }
        }

        protected override IList<string> Errors
        {
            get { return (from x in this where !x.IsPerformed select x.Message).ToList(); }
        }

        public override string ToString()
        {
            return FlatErrors;
        }
    }

    public class OperationResultCollection<T> : ResultCollectionBase<OperationResult<T>> where T : new()
    {
        public override bool ThereAreErrors
        {
            get { return this.Any(x => !x.IsPerformed); }
        }

        protected override IList<string> Errors
        {
            get { return (from x in this where !x.IsPerformed select x.Message).ToList(); }
        }

        public override string ToString()
        {
            return FlatErrors;
        }
    }
}
